#include "../Base/stdafx.h"
#include "../Base/DXDevice.h"
#include "Button.h"
#include "TextBox.h"
#include "Label.h"
#include "GUI.h"
#include <Boost/foreach.hpp>

GUI::GUI()
{
	m_Pos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
}

GUI::GUI( const D3DXVECTOR3& pos )
{
	m_Pos = pos;
}

GUI::GUI( int x, int y )
{
	m_Pos = D3DXVECTOR3((float)x, (float)y, 0.0f);
}

GUI::~GUI()
{
	BOOST_FOREACH(Button* x, m_Buttons) delete x;
	BOOST_FOREACH(TextBox* x, m_TextBoxen) delete x;
	BOOST_FOREACH(Label* x, m_Labels) delete x;
}

void GUI::Tick(float dTime)
{
	BOOST_FOREACH(Button* x, m_Buttons) x->Tick(dTime);
	BOOST_FOREACH(TextBox* x, m_TextBoxen) x->Tick(dTime);
	BOOST_FOREACH(Label* x, m_Labels) x->Tick(dTime);
}

void GUI::Paint()
{
	BOOST_FOREACH(Button* x, m_Buttons) x->Paint();
	BOOST_FOREACH(TextBox* x, m_TextBoxen) x->Paint();
	BOOST_FOREACH(Label* x, m_Labels) x->Paint();
}

int GUI::CreateButton(const tstring& text, const D3DXVECTOR3& pos, int width, int height, const tstring& name, bool image)
{
	Button *temp = new Button(text, pos, width, height, name, image);
	m_Buttons.push_back(temp);
	return m_Buttons.size()-1;
}

int GUI::CreateTextBox(const tstring& text, const D3DXVECTOR3& pos, int width, int height, const tstring& name, bool isPass)
{
	TextBox *temp = new TextBox(text, pos, width, height, name, isPass);
	m_TextBoxen.push_back(temp);
	return m_TextBoxen.size()-1;
}

int GUI::CreateTextBox(const D3DXVECTOR3& pos, int width, int height, const tstring& name, bool isPass)
{
	return CreateTextBox(_T(""), pos, width, height, name, isPass);
}

int GUI::CreateLabel(const tstring& text, const D3DXVECTOR3& pos, const tstring& name)
{
	Label *temp = new Label(text, pos, name);
	m_Labels.push_back(temp);
	return m_Labels.size()-1;
}